/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sreams;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

/**
 *
 * @author Educacionit
 */
public class Copiador {

    public static boolean copiar(String entrada, String salida) {
        File fEntrada = new File(entrada);
        File fSalida = new File(salida);

        FileReader in = null;
        FileWriter out = null;
        BufferedReader bin = null;
        BufferedWriter bout = null;

        try {
            in = new FileReader(fEntrada);
            out = new FileWriter(fSalida);

            bin = new BufferedReader(in);
            bout = new BufferedWriter(out);

            while (bin.ready()) {
                bout.write(bin.readLine());
                bout.newLine();
            }

        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            try { bin.close(); }
            catch (Exception e) { e.printStackTrace(); return false; }

            try { bout.close(); }
            catch (Exception e) { e.printStackTrace(); return false;}

            try { in.close(); }
            catch (Exception e) { e.printStackTrace(); return false;}

            try { out.close(); }
            catch (Exception e) { e.printStackTrace(); return false;}
        }

        return true;
    }
}
